"""
ASGI config for scodepub project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

from channels.routing import URLRouter
from channels.routing import ProtocolTypeRouter
from . import routing

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'scodepub.settings')

# application = get_asgi_application()          #注释掉原来额 application
application=ProtocolTypeRouter(
    {
        "http":get_asgi_application(),      #http请求 走默认的asgi
        "websocket":URLRouter(routing.websocket_urlpatterns),                      #websocket 走channels通道
    }
)